<?php
/*
后台刮奖结果
*/
if(!defined('BASEPATH')) exit('No direct script access allowed');
Class Weixin_Actioninfo_result_module extends CI_Module
{
	public $setting;
	public $aid;
	public $sid;
	public $adminid;
	public function __construct()
    {
        parent::__construct();
		$this->sid = $GLOBALS['sid'];
		$this->load->model('weixin.weixin_model');
        $this->load->model('expert.Expert_model');
		$this->load->library("pagination");
        $this->setting = $this->weixin_model->db_get_setting();
        define('TOKEN', @$this->setting['token']);
        define('APPID', @$this->setting['appid']);
        define('APPSECRET', @$this->setting['appsecret']);
        $this->adminid = $this->session->userdata('admin_user_id');
        if (!$this->adminid) {
            redirect(site_url('admin/index/login'));
        }
		$id=$this->uri->segment(4,0);
		$this->aid=$id?$id:1;							    
		$this->load->model('weixin.actioninfo_result_model');			//加载模型，附值初始活动id
    }
	function index($id=""){
		$pagenum=15;
		$allnum=count($this->actioninfo_result_model->num_result($this->sid));

		$config['uri_segment'] = 4;
		$config['total_rows']=$allnum;   		//CI配置文件 总共的条数
		$config['per_page']=$pagenum;			//CI配置文件，一页显示条数
		$config['num_links']=3;					//当前页前后要显示的几个分页连接

		$config['base_url']=site_url("/weixin/actioninfo_result/index");
		$config['use_page_numbers']=true;
		$config['first_link'] = '第一页';
		$config['last_link'] = '最后一页';
		//调用分类页
		$this->pagination->initialize($config);
		$productlist['pagelists']=$this->pagination->create_links()."<br/>";

		$id=$id?$id:1;
		$startpage=($id-1)*$pagenum;			//第几页从第几条开始显示
		$productlist['list']=$this->actioninfo_result_model->sel_result_page($startpage,$pagenum,$this->sid);	//倒序排列
		#endregin  分页完成
		
		#region    添加页 活动类型		
		$productlist['view']='action/actioninfo_result_view';
		$productlist['title']='刮奖结果查看';
		$this->loadview($productlist, 'xenon/common/index');
	}
	
	//修改  连接得到ID，url的第三段
	function result_up(){
		date_default_timezone_set('Asia/Shanghai');
		$time = date('Y-m-d H:i:s');
		$arr1=array("isoperate"=>1,"admintime"=>$time);
		$this->actioninfo_result_model->update_one($this->aid,$arr1);
		echo"<script>window.location='".site_url('/weixin/actioninfo_result')."';</script>";
	
	}
	
}
?>